package com.itheima.el;

import com.itheima.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/*
* el综合案例*/
@WebServlet("/demo4")
public class ServletDemo4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HashMap<String, List<User>> map1 = new HashMap<>();
        User user1 = new User("张山1", 15, new Date());
        User user2 = new User("张山2", 15, new Date());
        User user3 = new User("张山3", 15, new Date());
        List<User> list1 = new ArrayList<>();
        list1.add(user1);
        list1.add(user2);
        list1.add(user3);


        User user11 = new User("张山11", 15, new Date());
        User user12= new User("张山12", 15, new Date());
        User user13= new User("张山13", 15, new Date());
        List<User> list2 = new ArrayList<>();
        list2.add(user11);
        list2.add(user12);
        list2.add(user13);
        map1.put("maplist1",list1);
        map1.put("map.list2",list2);

        req.setAttribute("Map",map1);
        req.getRequestDispatcher("/el4.jsp").forward(req,resp);

    }
}
